<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>组织机构编辑</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/libs/layui2.2.5/css/layui.css">
    <link rel="icon" href="href="${pageContext.request.contextPath}/static/libs/uiframe/frame/static/image/code.png">
</head>
<body>
    <form class="layui-form" style="padding-top: 20px;" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">机构名称：</label>
            <div class="layui-input-inline">
                <input type="text" name="orgName" value="${org.orgName}"
                       autocomplete="off" placeholder="请输入组织机构名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否锁定：</label>
            <div class="layui-input-block">
                <c:choose>
                    <c:when test="${org.locked == 'true'}">
                        <input type="radio" name="locked" value="true" title="是" >
                        <input type="radio" name="locked" value="false" title="否" checked="checked" >
                    </c:when>
                    <c:when test="${org.locked == 'false'}">
                        <input type="radio" name="locked" value="true" title="是" checked="checked" >
                        <input type="radio" name="locked" value="false" title="否" >
                    </c:when>
                    <c:otherwise>
                        <input type="radio" name="locked" value="true" title="是" >
                        <input type="radio" name="locked" value="false" title="否" checked="checked">
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序编号：</label>
            <div class="layui-input-inline">
                <input type="text" name="sortedNum"
                       value="${org.sortedNum}" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系电话：</label>
            <div class="layui-input-inline">
                <input type="text" name="telephone" value="${org.telephone}"
                       autocomplete="off" placeholder="请输入联系电话" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">电子邮件：</label>
            <div class="layui-input-inline">
                <input type="text" name="email" value="${org.email}"
                       autocomplete="off" placeholder="请输入电子邮件" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">电子传真：</label>
            <div class="layui-input-inline">
                <input type="text" name="fax" value="${org.fax}"
                       autocomplete="off" placeholder="请输入电子邮件" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">管理员：</label>
            <div class="layui-input-inline">
                <input type="text" name="administr" value="${org.administr}"
                       autocomplete="off" placeholder="请输入管理员" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">机构地址：</label>
            <div class="layui-input-inline">
                <input type="text" name="address" value="${org.address}"
                       autocomplete="off" placeholder="请输入组织机构地址" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">机构描述：</label>
            <div class="layui-input-inline">
                <input type="text" name="description" value="${org.description}"
                       placeholder="请输入机构描述" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="roleadd">提 交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重 置</button>
            </div>
        </div>
    </form>

<script type="text/javascript" src="${pageContext.request.contextPath}/static/libs/layui2.2.5/layui.js"></script>
<script>
    var orgId = '${org.roleId}',parentId = '${parentid}';

    layui.use(['form','layer'],function(){
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer;

            //监听提交
        form.on('submit(roleadd)', function(data){
            var formData = data.field,url;
            if(orgId == ""){
                url = '${pageContext.request.contextPath}/sys/user/orgcreate';
            }else{
                orgId = '${pageContext.request.contextPath}/sys/user/orgupdate';
            }
            $.ajax({
                type:'post',
                dataType:'json',
                url:url,
                data:{
                    parentId:parentId,
                    orgId:orgId,
                    orgName:formData['orgName'],
                    locked:formData['locked'],
                    sortedNum:formData['sortedNum'],
                    telephone:formData['telephone'],
                    email:formData['email'],
                    fax:formData['fax'],
                    administr:formData['administr'],
                    address:formData['address'],
                    description:formData['description']
                },
                success:function (data) {
                    layer.msg(data.status);
                    window.parent.layIndex = null;
                    window.parent.closeAllLayer();
                },
                error:function (error) {
                    console.log(error);
                }
            });
            return false;
        });
    })
</script>
</body>
</html>
